<?php

namespace app\api\service;


use app\api\model\ImageCategory;
use app\api\model\ImageList;

class ImageService
{
    public static function getImagesList($params)
    {
        $categoryInfo = ImageCategory::getInfoById($params['category_id']);
        if (!$categoryInfo) return [201, '分类不存在', []];
        $imageList = ImageList::getListByCategoryId($params['category_id']);
        if (!$imageList) return [200, '无图片配置', []];
        $dealImage = [];
        foreach ($imageList as $item) {
            $dealImage[] = [
                'image_id' => $item['image_id'],
                'image_src' => dealImage($item['image_src']),
            ];
        }
        if (!$dealImage) return [200, '无图片配置', []];
        $returnImages = [];
        if (!$categoryInfo['category_mode']) $returnImages[] = $dealImage[0];
        else $returnImages = $dealImage;
        return [200, '操作成功', $returnImages];
    }
}